Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scattered Optimizations #815

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nbollis
Copy link
Member

@nbollis nbollis commented Dec 13, 2024

This pull request optimizes memory usage and performance across several files by introducing object pooling and other efficiency improvements.

  • Added DictionaryPool.cs and HashSetPool.cs for pooling Dictionary and HashSet instances.
  • ClassicDeconvolutionAlgorithm.cs: Reused HashSet instances from pools to reduce memory allocations.
  • DeconvolutionAlgorithm.cs: Added HashSetPool<int> and HashSetPool<double> for pooling hash sets.
  • PpmTolerance.cs: Optimized methods using a precomputed _factor field.
  • PeptideWithSetModifications.cs: Enabled nullable reference types and optimized memory usage with StringBuilder and HashSetPool<double>.
  • BioPolymerWithSetModsExtensions.cs: Implemented string interpolation instead of concatenation and optimized memory usage with StringBuilder
  • Digestion:
    • DigestionAgent.cs: Reused HashSet instances from pools to reduce memory allocations
    • DigestionProduct.cs: Reduced calls to ModFits by altering boolean check order
    • Protease.cs Reduced list creation events
    • ProteolyticPeptide.cs Reused Dictionary instances from pools to reduce memory allocations
  • IBioPolymerWithSetMods:
    • Removed unnecessary IEquatable<> reference in interface
    • PeptideWithSetModifications.cs: Reused HashSet instances from pools to reduce memory allocations.

…der simplificaiton in BioPolymerWithSetModsExtensions
Modified DetermineFullSequence to reduce StringBuilder resizes.
Added Microsoft.Extensions.ObjectPool dependency.
Introduced ObjectPoolTests for DictionaryPool and HashSetPool.
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

Attention: Patch coverage is 91.24424% with 19 lines in your changes missing coverage. Please review.

Project coverage is 77.25%. Comparing base (21c1702) to head (0575432).

Files with missing lines Patch % Lines
mzLib/Omics/IBioPolymerWithSetMods.cs 60.00% 0 Missing and 4 partials ⚠️
mzLib/Proteomics/Protein/Protein.cs 20.00% 4 Missing ⚠️
...zLib/Transcriptomics/Digestion/OligoWithSetMods.cs 42.85% 2 Missing and 2 partials ⚠️
...ib/Omics/Modifications/ModificationLocalization.cs 93.75% 0 Missing and 2 partials ⚠️
...roteolyticDigestion/PeptideWithSetModifications.cs 94.87% 1 Missing and 1 partial ⚠️
...lution/Algorithms/ClassicDeconvolutionAlgorithm.cs 92.85% 0 Missing and 1 partial ⚠️
mzLib/Omics/BioPolymerWithSetModsExtensions.cs 94.44% 1 Missing ⚠️
mzLib/Omics/IBioPolymer.cs 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #815      +/-   ##
==========================================
+ Coverage   77.23%   77.25%   +0.01%     
==========================================
  Files         218      220       +2     
  Lines       33014    33081      +67     
  Branches     3422     3436      +14     
==========================================
+ Hits        25499    25556      +57     
- Misses       6942     6949       +7     
- Partials      573      576       +3     
Files with missing lines Coverage Δ
...Deconvolution/Algorithms/DeconvolutionAlgorithm.cs 100.00% <100.00%> (ø)
mzLib/MzLibUtil/DictionaryPool.cs 100.00% <100.00%> (ø)
mzLib/MzLibUtil/HashSetPool.cs 100.00% <100.00%> (ø)
mzLib/MzLibUtil/PpmTolerance.cs 100.00% <100.00%> (ø)
mzLib/Omics/Digestion/DigestionAgent.cs 90.90% <100.00%> (+0.52%) ⬆️
mzLib/Omics/Digestion/DigestionProduct.cs 95.65% <100.00%> (+0.87%) ⬆️
mzLib/Proteomics/ProteolyticDigestion/Protease.cs 95.17% <100.00%> (ø)
...teomics/ProteolyticDigestion/ProteolyticPeptide.cs 92.03% <100.00%> (+0.14%) ⬆️
mzLib/Transcriptomics/NucleicAcid.cs 92.70% <100.00%> (-0.31%) ⬇️
...lution/Algorithms/ClassicDeconvolutionAlgorithm.cs 96.55% <92.85%> (-0.38%) ⬇️
... and 7 more

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant